#{set title:'Autoriser candidatures'/}
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/main.css'}" />
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/datatable_jui.css'}" />
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/jquery-ui-1.8.4.custom.css'}" />
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/javascripts/jquery-ui-1.8.13.custom/css/ui-lightness/jquery-ui-1.8.13.custom.css'}" />

<script src="@{'/public/javascripts/menuDeroulant.js'}" type="text/javascript" ></script>
<script src="@{'/public/javascripts/jquery-1.5.min.js'}" type="text/javascript" ></script>
<script src="@{'/public/javascripts/DataTables-1.7.5/media/js/jquery.dataTables.js'}" type="text/javascript" ></script>
<script type="text/javascript">
	$(document).ready(function() {
	    oTable = $('.display').dataTable({
	        "bJQueryUI": true,
	        "sPaginationType": "full_numbers"
	    });
	});
</script>

<div class="post">
        <h2 class="post-title">
			#{if listeCandidats.size != 0}
            	Liste des candidatures de ${listeCandidats.get(0).agent.cis} en attente autorisation
			
        </h2>
        <br>
			#{form @envoieAutorisation()}
			<table width="200" cellspacing='0' cellpadding='7' id="liste" class="display" summary="Liste des candidats" bgcolor="#E1EEF0">
				<thead>
					<tr>
						<th>Nom</th>
						<th>Pr&eacute;nom</th>
						<th>Statut</th>
						<th>Role</th>
						<th>Code Stage</th>
						<th>CIS ou Service</th>
					 	<th>Structure de coordination</th> 
					 	<th>Priorit&eacute;</th>
						<th>Autorisation</th>
						<th>Pr&eacute;cisions</th>
					</tr>
				</thead>
				<tbody>
				    #{list items:listeCandidats, as:'candid' }
    		       	<tr>
        		           	<td><a href="@{candidats.detailCandid(candid.id)}">${candid.agent.nom}<a href="@{candidats.detailCandid(candidature.id)}"></td>
           		           	<td>${candid.agent.prenom}</td>
        				   	<td>${candid.agent.statut}</td>
							<td>${candid.role}</td>
							<td>
	        	            	#{if candid.stage!=null}
	        	                	<a href="@{Stages.detailStage(candid.stage.id)}">${candid.getStage().getCode()}</a>
	        	                #{/if}
	                            #{else}
	                            	Stage non planifi&eacute;
	                            #{/else}
        	            	</td>
        				   	<td>${candid.agent.cis} </td>
        				   	<td> ${candid.agent.structureCoord} </td>
        				   	<td>
        				   		<select id="priorite" name="priorite">
        				   			<option>-- Choisir une valeur --</option>
        				   			<option value="1">1</option>
        				   			<option value="2">2</option>
        				   			<option value="3">3</option>
        				   			<option value="4">4</option>
        				   			<option value="5">5</option>
        				   			<option value="6">6</option>
       				   			</select>
    				   		</td>
        				   	<td>
        				   	        Oui :<input type="radio" name="${candid.id}" id="O${candid.id}" value="oui" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false; testBox('${candid.id}')"><br/>
        				   	        Non :<input type="radio" name="${candid.id}" id="N${candid.id}" value="non" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false; testBox('${candid.id}')">
        				   	</td>
        				    <td>
        				        <input type="text" class="precisions" id="R${candid.id}" name="R${candid.id}" disabled />
        				    </td>
    		       	</tr>
       			    #{/list} 
		       	</tbody> 
			</table>
			<br />
			<input type="submit" value="Valider changement" style="float:right;"/>
			<input type="hidden" value="${id}" name="id" />
		#{/form}
		#{/if}
		#{else}
			Aucune candidature en attente d'autorisation pour ce CIS ou service
		#{/else}
    </div>
	<script TYPE="text/javascript">
	function testBox(id){
		if(document.getElementById("N"+id).checked){
			document.getElementById("R"+id).disabled=false;
		}
		else{
			document.getElementById("R"+id).disabled=true;
			document.getElementById("R"+id).value="";
		}
	}
	</script>